import React, { Component } from 'react'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { getsplist } from '../../redux/actionCreator'

class CountyDetail extends Component {
    constructor(props) {
        super(props);
        this.props.dispatch(getsplist());
    }
    render() {
        console.log(this.props.shop)
        // this.props.shop.map((item,index)=>{
        //     item.commodity_id.slice(0,1)==
        // })
        // let { county } = this.props
        console.log(this.props)
        // console.log((this.props.location.search.split('?')[1].split('=')[1]))
        // let detailmsg = county.filter((item, index) => item.county_id == this.props.location.search.split('?')[1].split('=')[1])
        // console.log(JSON.stringify(detailmsg[0]))
        // localStorage.setItem('countydetail', JSON.stringify(detailmsg[0]));
        // console.log((localStorage.getItem('countydetail')))
        return (
            <div style={{ minHeight: '100vh', display: 'flex' }}>
                <div style={{ backgroundColor: "#080904", minHeight: '100vh', display: 'flex', width: '100%' }}>
                    <div style={{ width: '90%', margin: '0 auto' }}>
                        <div style={{ height: '20px' }}></div>
                        <i className="iconfont icon-fanhui" style={{ fontSize: '1.7em' }} onClick={() => this.props.history.goBack()}></i>
                        <div style={{ textAlign: 'center', fontSize: '1.5em', fontWeight: 'bold', paddingTop: '25px', paddingBottom: '20px' }}>石家庄·{JSON.parse(localStorage.getItem('countyDetail')).county_name}</div>
                        <div style={{ border: '1px solid', height: '200px', width: '100%' }}>
                            <img style={{ height: '100%', width: '100%' }} src={`http://www.h5weixin.club:1025/api/image/${JSON.parse(localStorage.getItem('countyDetail')).county_pic}`}></img>
        {/* <div>{this.props.shop[0].commodity_id}</div> */}
                        </div>
                        <button 
                        style={{marginTop:'1em',height:'2em',width:'5em',borderRadius:'20px',backgroundColor:'#F68D47'}} 
                        onClick={()=>this.props.history.push({
                            pathname:'/detaillist',
                            search:`${this.props.location.search.split('?')[1]}`
                        })

                        }>采摘详情</button>
                        <div style={{marginTop:'1em',fontSize:'1.3em',lineHeight:'25px',textIndent:'2em'}}>{JSON.parse(localStorage.getItem('countyDetail')).county_describe}</div>
                        <div style={{ fontSize: '1.5em', fontWeight: 'bold', marginTop: '1.5em' ,borderBottom:'1px solid #ccc',padding:'0.5em'}}>历史沿革</div>
                        <div style={{marginTop:'1.2em',fontSize:'1.3em',lineHeight:'25px',textIndent:'2em'}}>{JSON.parse(localStorage.getItem('countyDetail')).county_history}</div>
                        <div style={{height:'1.2em'}}></div>
                    </div>

                </div>

                <div style={{ flex: '1' }}></div>
            </div>
        )
    }
}

const mapStateToProps = (state) => ({
    shop: state.shop
})

export default withRouter(connect(mapStateToProps)(CountyDetail))
